<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.0.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">
  <link rel="alternate" href="/atom.xml" title="itheone" type="application/atom+xml">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '7.5.0',
    exturl: true,
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
    copycode: {"enable":true,"show_result":true,"style":"default"},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":true},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: '',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    sidebarPadding: 40
  };
</script>

  <meta name="description" content="[toc]jenkins安装及使用（centos_7）下载安装 官方网址：https:&#x2F;&#x2F;jenkins.io&#x2F;zh&#x2F;download&#x2F; 123456## 配置仓库和密钥sudo wget -O &#x2F;etc&#x2F;yum.repos.d&#x2F;jenkins.repo https:&#x2F;&#x2F;pkg.jenkins.io&#x2F;redhat-stable&#x2F;jenkins.reposudo rpm --import https">
<meta property="og:type" content="article">
<meta property="og:title" content="centos7安装jenkins">
<meta property="og:url" content="https:&#x2F;&#x2F;www.caohaifeng.site&#x2F;2019&#x2F;12&#x2F;11&#x2F;centos7%E5%AE%89%E8%A3%85jenkins&#x2F;index.html">
<meta property="og:site_name" content="itheone">
<meta property="og:description" content="[toc]jenkins安装及使用（centos_7）下载安装 官方网址：https:&#x2F;&#x2F;jenkins.io&#x2F;zh&#x2F;download&#x2F; 123456## 配置仓库和密钥sudo wget -O &#x2F;etc&#x2F;yum.repos.d&#x2F;jenkins.repo https:&#x2F;&#x2F;pkg.jenkins.io&#x2F;redhat-stable&#x2F;jenkins.reposudo rpm --import https">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;hevolf&#x2F;itheone_resource_images&#x2F;master&#x2F;img&#x2F;jenkins%E6%9E%84%E5%BB%BAmvn%E6%8A%A5%E9%94%99.png">
<meta property="og:image" content="https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;hevolf&#x2F;itheone_resource_images&#x2F;master&#x2F;img&#x2F;tomcat%E7%83%AD%E9%83%A8%E7%BD%B2%E8%AE%BF%E9%97%AE%E9%99%90%E5%88%B6.png">
<meta property="og:image" content="https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;hevolf&#x2F;itheone_resource_images&#x2F;master&#x2F;img&#x2F;tomcat%E5%BC%80%E5%90%AF%E7%94%A8%E6%88%B7.png">
<meta property="og:updated_time" content="2019-12-11T09:03:57.998Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;hevolf&#x2F;itheone_resource_images&#x2F;master&#x2F;img&#x2F;jenkins%E6%9E%84%E5%BB%BAmvn%E6%8A%A5%E9%94%99.png">

<link rel="canonical" href="https://www.caohaifeng.site/2019/12/11/centos7%E5%AE%89%E8%A3%85jenkins/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>centos7安装jenkins | itheone</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">itheone</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <p class="site-subtitle">H</p>
  </div>

  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
        <li class="menu-item menu-item-schedule">

    <a href="/schedule/" rel="section"><i class="fa fa-fw fa-calendar"></i>日程表</a>

  </li>
        <li class="menu-item menu-item-commonweal">

    <a href="/404/" rel="section"><i class="fa fa-fw fa-heartbeat"></i>公益 404</a>

  </li>
  </ul>

</nav>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

  <span class="exturl github-corner" data-url="aHR0cHM6Ly9naXRodWIuY29tL2hldm9sZg==" title="Follow me on GitHub" aria-label="Follow me on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></span>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content">
            

  <div class="posts-expand">
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block " lang="zh-CN">


  
  
  
    <div class="bottom-divider">
      <style>
        .bottom-divider {
          display: table;
          padding-bottom: 10px;
          margin-bottom: 50px;
          width: 100%;
          border-bottom: 1px solid #eee;
        }
      </style>
      <div class="post-nav-next post-nav-item">
        
          <a href="/2019/11/27/JVM/" rel="next" title="JVM">
            <i class="fa fa-chevron-left"></i> JVM
          </a>
        
      </div>

      <span class="post-nav-divider"></span>

      <div class="post-nav-prev post-nav-item">
        
          <a href="/2019/12/11/Java%E6%AF%8F%E6%97%A5%E4%B8%80%E9%A2%98/" rel="prev" title="java每日一题">
            java每日一题 <i class="fa fa-chevron-right"></i>
          </a>
        
      </div>
    </div>
  

  
  
  
  
    
  
    <link itemprop="mainEntityOfPage" href="https://www.caohaifeng.site/2019/12/11/centos7%E5%AE%89%E8%A3%85jenkins/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="Haifeng Cao">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="itheone">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          centos7安装jenkins
        </h1>

        <div class="post-meta">

			
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2019-12-11 19:27:20 / 修改时间：17:03:57" itemprop="dateCreated datePublished" datetime="2019-12-11T19:27:20+08:00">2019-12-11</time>
            </span>

          
            <span id="/2019/12/11/centos7%E5%AE%89%E8%A3%85jenkins/" class="post-meta-item leancloud_visitors" data-flag-title="centos7安装jenkins" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2019/12/11/centos7%E5%AE%89%E8%A3%85jenkins/#comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2019/12/11/centos7%E5%AE%89%E8%A3%85jenkins/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>3.5k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>3 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>[toc]</p><h1 id="jenkins安装及使用（centos-7）"><a href="#jenkins安装及使用（centos-7）" class="headerlink" title="jenkins安装及使用（centos_7）"></a>jenkins安装及使用（centos_7）</h1><h2 id="下载安装"><a href="#下载安装" class="headerlink" title="下载安装"></a>下载安装</h2><ol>
<li>官方网址：<span class="exturl" data-url="aHR0cHM6Ly9qZW5raW5zLmlvL3poL2Rvd25sb2FkLw==" title="https://jenkins.io/zh/download/">https://jenkins.io/zh/download/<i class="fa fa-external-link"></i></span></li>
</ol><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"><span class="comment"># 配置仓库和密钥</span></span></span><br><span class="line">sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo</span><br><span class="line">sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 安装（速度慢）</span></span><br><span class="line">yum install jenkins</span><br></pre></td></tr></table></figure><a id="more"></a>


<ol start="2">
<li>yum方式安装比较慢 最好直接下载rpm文件再安装</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"><span class="comment"># 安装rpm文件</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> rpm -ivh jenkins-2.190.3-1.1.noarch.rpm </span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"><span class="comment"># 启动暂停</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> sudo service jenkins start/stop/restart</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> systemctl start/stop/restart jenkins</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"><span class="comment"># 开机启动</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> sudo chkconfig jenkins on</span></span><br></pre></td></tr></table></figure>
<h2 id="启动报错"><a href="#启动报错" class="headerlink" title="启动报错"></a>启动报错</h2><ol>
<li>启动报错<br><code>service jenkins start</code></li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Starting jenkins (via systemctl):  Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.</span><br><span class="line">                                                           [FAILED]</span><br></pre></td></tr></table></figure>


<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"><span class="comment"># 查看报错信息 /usr/bin/java命令找不到,java环境变量路径不对</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> systemctl status jenkins.service</span></span><br><span class="line"></span><br><span class="line">Dec 09 09:36:18 localhost.localdomainA jenkins[7311]: Starting Jenkins bash: /usr/bin/java: No such file or directory</span><br><span class="line">Dec 09 09:36:18 localhost.localdomainA jenkins[7311]: [FAILED]</span><br><span class="line">Dec 09 09:36:18 localhost.localdomainA systemd[1]: Failed to start LSB: Jenkins Automation Server.</span><br><span class="line">Dec 09 09:36:18 localhost.localdomainA systemd[1]: jenkins.service failed.</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"><span class="comment"># 解决方案：创建软连接</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> ln -s /usr/<span class="built_in">local</span>/src/jdk1.8.0_201/bin/java /usr/bin/java</span></span><br><span class="line"><span class="meta">#</span><span class="bash"><span class="comment"># 重新启动成功</span></span></span><br></pre></td></tr></table></figure>
<ol start="2">
<li><p>浏览器重启jenkins：<br><span class="exturl" data-url="aHR0cDovLzE5Mi4xNjguNjguMTA6MTgwODAvcmVzdGFydA==" title="http://192.168.68.10:18080/restart">http://192.168.68.10:18080/restart<i class="fa fa-external-link"></i></span><br><span class="exturl" data-url="aHR0cDovLzE5Mi4xNjguNjguMTA6MTgwODAvcmVsb2Fk" title="http://192.168.68.10:18080/reload">http://192.168.68.10:18080/reload<i class="fa fa-external-link"></i></span></p>
</li>
<li><p>登录jenkins<br>管理员初始密码</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> cat /var/lib/jenkins/secrets/initialAdminPassword</span></span><br></pre></td></tr></table></figure>



</li>
</ol>
<h2 id="相关参数"><a href="#相关参数" class="headerlink" title="相关参数"></a>相关参数</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"><span class="comment"># 查看Jenkins安装的文件</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> rpm -ql jenkins</span></span><br><span class="line"></span><br><span class="line">/etc/init.d/jenkins</span><br><span class="line">/etc/logrotate.d/jenkins</span><br><span class="line">/etc/sysconfig/jenkins</span><br><span class="line">/usr/lib/jenkins</span><br><span class="line">/usr/lib/jenkins/jenkins.war</span><br><span class="line">/usr/sbin/rcjenkins</span><br><span class="line">/var/cache/jenkins</span><br><span class="line">/var/lib/jenkins</span><br><span class="line">/var/log/jenkins</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"><span class="comment"># 初始密码</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> cat /var/lib/jenkins/secrets/initialAdminPassword</span></span><br></pre></td></tr></table></figure>


<ul>
<li><code>/usr/lib/jenkins/</code>：jenkins安装目录，war包会放在这里。</li>
<li><code>/etc/sysconfig/jenkins</code>：jenkins配置文件，<strong>端口</strong>，<strong>JENKINS_HOME</strong>等都可以在这里配置。</li>
<li><code>/var/lib/jenkins/</code>：默认的JENKINS_HOME, 默认的<strong>workspace</strong>也在此目录下。</li>
<li><code>/var/log/jenkins/jenkins.log</code>：jenkins日志文件。</li>
<li><code>/var/lib/jenkins/secrets/initialAdminPassword</code>：第一次登录初始密码</li>
</ul>
<h2 id="插件管理"><a href="#插件管理" class="headerlink" title="插件管理"></a>插件管理</h2><ol>
<li><p>镜像<br>默认镜像：<span class="exturl" data-url="aHR0cHM6Ly91cGRhdGVzLmplbmtpbnMuaW8vdXBkYXRlLWNlbnRlci5qc29u" title="https://updates.jenkins.io/update-center.json">https://updates.jenkins.io/update-center.json<i class="fa fa-external-link"></i></span><br>清华镜像：<span class="exturl" data-url="aHR0cHM6Ly9taXJyb3JzLnR1bmEudHNpbmdodWEuZWR1LmNuL2plbmtpbnMvdXBkYXRlcy91cGRhdGUtY2VudGVyLmpzb24=" title="https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json">https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json<i class="fa fa-external-link"></i></span></p>
</li>
<li><p>安全矩阵插件：<code>Matrix Authorization Strategy Plugin</code></p>
</li>
<li><p>持续集成需要用到的工具：</p>
<ul>
<li>git plugin<br><code>This plugin integrates Git with Jenkins</code></li>
<li>maven integrate<br><code>This plug-in provides, for better and for worse, a deep integration of Jenkins and Maven: Automatic triggers between projects depending on SNAPSHOTs, automated configuration of various Jenkins publishers (Junit, ...).</code></li>
<li>Deploy to container</li>
</ul>
</li>
</ol>
<h2 id="构建配置"><a href="#构建配置" class="headerlink" title="构建配置"></a>构建配置</h2><ol>
<li>手动构建</li>
<li>定时构建</li>
<li>轮询构建<ul>
<li>定时</li>
<li>代码有更新</li>
</ul>
</li>
</ol>
<h2 id="构建报错"><a href="#构建报错" class="headerlink" title="构建报错"></a>构建报错</h2><p><strong>报错提示：</strong><code>Failed to transfer Could not transfer artifact</code><br><strong>报错原因：</strong>maven安装后，无自定义仓库路径的操作权限导致无法pull pom依赖包（无操作权限）</p>
<p><img src="https://raw.githubusercontent.com/hevolf/itheone_resource_images/master/img/jenkins%E6%9E%84%E5%BB%BAmvn%E6%8A%A5%E9%94%99.png" alt></p>
<h2 id="自动部署"><a href="#自动部署" class="headerlink" title="自动部署"></a>自动部署</h2><ol>
<li><p>使用插件Deploy to container<br>如果是在linux上部署Tomcat，需要使用/manger访问，一般需要开放访问限制Tomcat目录/webapps/manager/META-INF/context.xml</p>
<p><img src="https://raw.githubusercontent.com/hevolf/itheone_resource_images/master/img/tomcat%E7%83%AD%E9%83%A8%E7%BD%B2%E8%AE%BF%E9%97%AE%E9%99%90%E5%88%B6.png" alt></p>
<p>修改Tomcat用户信息：Tomcat目录/conf/tomcat-users.xml</p>
<p><img src="https://raw.githubusercontent.com/hevolf/itheone_resource_images/master/img/tomcat%E5%BC%80%E5%90%AF%E7%94%A8%E6%88%B7.png" alt></p>
</li>
<li><p>使用shell脚本</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">!/bin/sh</span></span><br><span class="line"><span class="meta">#</span><span class="bash"><span class="built_in">kill</span> tomcat pid</span></span><br><span class="line"><span class="meta">#</span><span class="bash">这句尤为重要,（防止tomcat进程随 shell命令进程结束而结束）</span></span><br><span class="line">export BUILD_ID=apache-tomcat-app_build_id</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 1.关闭tomcat</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> grep -v <span class="string">"grep"</span> 反向筛选，即过滤grep进程</span></span><br><span class="line">pidlist=`ps -ef|grep apache-tomcat-app|grep -v "grep"|awk '&#123;print $2&#125;'`</span><br><span class="line">function stop()&#123;</span><br><span class="line">if [ "$pidlist" == "" ]</span><br><span class="line">  then</span><br><span class="line">    echo "----tomcat 已经关闭----"</span><br><span class="line">    </span><br><span class="line"> else</span><br><span class="line">    echo "tomcat进程号 :$pidlist"</span><br><span class="line">    kill -9 $pidlist</span><br><span class="line">    echo "KILL $pidlist:"</span><br><span class="line">fi</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">stop</span><br><span class="line"></span><br><span class="line">pidlist2=`ps -ef|grep apache-tomcat-app|grep -v "grep"|awk '&#123;print $2&#125;'`</span><br><span class="line">if [ "$pidlist2" == "" ]</span><br><span class="line">    then </span><br><span class="line">       echo "----关闭tomcat成功----"</span><br><span class="line">else</span><br><span class="line">    echo "----关闭tomcat失败----"</span><br><span class="line">fi</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 2.移除原来tomcat中webapps中的项目文件夹</span></span><br><span class="line">rm -rf /home/king/apache-tomcat-app/webapps/ROOT*</span><br><span class="line"><span class="meta">#</span><span class="bash"> 3.复制jenkins生成的war包到tomcat中webapps中</span></span><br><span class="line">cp -r /home/king/.jenkins/workspace/enjoy-king/target/enjoy-git-1.0.war  /home/king/apache-tomcat-app/webapps</span><br><span class="line">sleep 3s</span><br><span class="line"><span class="meta">#</span><span class="bash"> 4.修改war包的名称（不需使用项目名即可访问）</span></span><br><span class="line">mv /home/king/apache-tomcat-app/webapps/enjoy-git-1.0.war  /home/king/apache-tomcat-app/webapps/ROOT.war</span><br><span class="line"><span class="meta">#</span><span class="bash"> 5.启动tomcat</span></span><br><span class="line">cd /home/king/apache-tomcat-app/bin</span><br><span class="line">./startup.sh</span><br></pre></td></tr></table></figure>


</li>
</ol>
<ol start="3">
<li>远程部署<br>安装ssh插件</li>
</ol>

    </div>

    


<div>
  
    <div>
    
	<br /> <br /> <br />
	<div style="text-align:center;color: #678;font-size:18px;">======================</div>
        <div style="text-align:center;color: #678;font-size:18px;">全 文 结 束&ensp;&ensp;<i class="fa fa-leanpub"></i>&ensp;&ensp;感 谢 阅 读</div>
	<div style="text-align:center;color: #678;font-size:18px;">======================</div>
    
</div>
  
</div>

    
    
    
        <div class="reward-container">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button disable="enable" onclick="var qr = document.getElementById(&quot;qr&quot;); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
      
      <div style="display: inline-block;">
        <img src="/images/wechatpay.png" alt="Haifeng Cao 微信支付">
        <p>微信支付</p>
      </div>
      
      <div style="display: inline-block;">
        <img src="/images/alipay.jpg" alt="Haifeng Cao 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>

        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>Haifeng Cao
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://www.caohaifeng.site/2019/12/11/centos7%E5%AE%89%E8%A3%85jenkins/" title="centos7安装jenkins">https://www.caohaifeng.site/2019/12/11/centos7%E5%AE%89%E8%A3%85jenkins/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <span class="exturl" data-url="aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzQuMC9udWxs"><i class="fa fa-fw fa-creative-commons"></i>BY-NC-SA</span> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">

        

          <div class="post-nav">
            <div class="post-nav-next post-nav-item">
                <a href="/2019/11/27/JVM/" rel="next" title="JVM">
                  <i class="fa fa-chevron-left"></i> JVM
                </a>
            </div>

            <span class="post-nav-divider"></span>

            <div class="post-nav-prev post-nav-item">
                <a href="/2019/12/11/Java%E6%AF%8F%E6%97%A5%E4%B8%80%E9%A2%98/" rel="prev" title="java每日一题">
                  java每日一题 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
      </footer>
    
  </article>
  
  
  

  </div>


          </div>
          
      <div class="tabs tabs-comment">
        <ul class="nav-tabs">
            <li class="tab"><a href="#comment-gitalk">gitalk</a></li>
            <li class="tab"><a href="#comment-valine">valine</a></li>
        </ul>
        <div class="tab-content">
            <div class="tab-pane gitalk" id="comment-gitalk">
              <div class="comments" id="gitalk-container"></div>
            </div>
            <div class="tab-pane valine" id="comment-valine">
              <div class="comments" id="comments"></div>
            </div>
        </div>
      </div>
      <script>
        window.addEventListener('tabs:register', () => {
          let activeClass = 'gitalk';
          if (activeClass) {
            let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
            if (activeTab) {
              activeTab.click();
            }
          }
        });
      </script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#jenkins安装及使用（centos-7）"><span class="nav-number">1.</span> <span class="nav-text">jenkins安装及使用（centos_7）</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#下载安装"><span class="nav-number">1.1.</span> <span class="nav-text">下载安装</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#启动报错"><span class="nav-number">1.2.</span> <span class="nav-text">启动报错</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#相关参数"><span class="nav-number">1.3.</span> <span class="nav-text">相关参数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#插件管理"><span class="nav-number">1.4.</span> <span class="nav-text">插件管理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#构建配置"><span class="nav-number">1.5.</span> <span class="nav-text">构建配置</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#构建报错"><span class="nav-number">1.6.</span> <span class="nav-text">构建报错</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#自动部署"><span class="nav-number">1.7.</span> <span class="nav-text">自动部署</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Haifeng Cao"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">Haifeng Cao</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">5</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">2</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="feed-link motion-element">
    <a href="/atom.xml" rel="alternate">
      <i class="fa fa-rss"></i>RSS
    </a>
  </div>
  <div class="chat motion-element"><i class="fa fa-comment"></i>
    Chat
  </a>
  </div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL2hldm9sZg==" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;hevolf"><i class="fa fa-fw fa-github"></i>GitHub</span>
      </span>
      <span class="links-of-author-item">
        <span class="exturl" data-url="bWFpbHRvOmNhb2hhaWZlbmd4QDE2My5jb20=" title="E-Mail → mailto:caohaifengx@163.com"><i class="fa fa-fw fa-envelope"></i>E-Mail</span>
      </span>
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cHM6Ly93ZWliby5jb20veW91cm5hbWU=" title="微博 → https:&#x2F;&#x2F;weibo.com&#x2F;yourname"><i class="fa fa-fw fa-weibo"></i>微博</span>
      </span>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title">
      <i class="fa fa-fw fa-link"></i>
      友情链接
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL2hldm9sZg==" title="https:&#x2F;&#x2F;github.com&#x2F;hevolf">GitHub</span>
        </li>
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly93d3cuYmFpZHUuY29t" title="https:&#x2F;&#x2F;www.baidu.com">百度</span>
        </li>
    </ul>
  </div>
<!-- CloudCalendar -->
<div class="widget-wrap" style="width: 90%;margin-left: auto;margin-right: auto; opacity: 0.97;">
	<div class="widget" id="CloudCalendar"></div>
</div>
      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Haifeng Cao</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    <span title="站点总字数">55k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">50 分钟</span>
</div>
  <div class="addthis_inline_share_toolbox">
    <script src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5dd7eec81a2121ca" async="async"></script>
  </div>

        






  <script>
  function leancloudSelector(url) {
    return document.getElementById(url).querySelector('.leancloud-visitors-count');
  }
  if (CONFIG.page.isPost) {
    function addCount(Counter) {
      var visitors = document.querySelector('.leancloud_visitors');
      var url = visitors.getAttribute('id').trim();
      var title = visitors.getAttribute('data-flag-title').trim();

      Counter('get', `/classes/Counter?where=${JSON.stringify({ url })}`)
        .then(response => response.json())
        .then(({ results }) => {
          if (results.length > 0) {
            var counter = results[0];
              leancloudSelector(url).innerText = counter.time + 1;
            Counter('put', '/classes/Counter/' + counter.objectId, { time: { '__op': 'Increment', 'amount': 1 } })
              .then(response => response.json())
              .catch(error => {
                console.log('Failed to save visitor count', error);
              })
          } else {
              Counter('post', '/classes/Counter', { title: title, url: url, time: 1 })
                .then(response => response.json())
                .then(() => {
                  leancloudSelector(url).innerText = 1;
                })
                .catch(error => {
                  console.log('Failed to create', error);
                });
          }
        })
        .catch(error => {
          console.log('LeanCloud Counter Error', error);
        });
    }
  } else {
    function showTime(Counter) {
      var visitors = document.querySelectorAll('.leancloud_visitors');
      var entries = [...visitors].map(element => {
        return element.getAttribute('id').trim();
      });

      Counter('get', `/classes/Counter?where=${JSON.stringify({ url: { '$in': entries } })}`)
        .then(response => response.json())
        .then(({ results }) => {
          if (results.length === 0) {
            document.querySelectorAll('.leancloud_visitors .leancloud-visitors-count').forEach(element => {
              element.innerText = 0;
            });
            return;
          }
          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.url;
            var time = item.time;
            leancloudSelector(url).innerText = time;
          }
          for (var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = leancloudSelector(url);
            if (element.innerText == '') {
              element.innerText = 0;
            }
          }
        })
        .catch(error => {
          console.log('LeanCloud Counter Error', error);
        });
    }
  }

  fetch('https://app-router.leancloud.cn/2/route?appId=932Lws0WCoOBR1QH1YcClNyO-gzGzoHsz')
    .then(response => response.json())
    .then(({ api_server }) => {
      var Counter = (method, url, data) => {
        return fetch(`https://${api_server}/1.1${url}`, {
          method: method,
          headers: {
            'X-LC-Id': '932Lws0WCoOBR1QH1YcClNyO-gzGzoHsz',
            'X-LC-Key': 'qhb4dhObEw9qngzRpoxXrtEw',
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(data)
        });
      };
      if (CONFIG.page.isPost) {
        const localhost = /http:\/\/(localhost|127.0.0.1|0.0.0.0)/;
        if (localhost.test(document.URL)) return;
        addCount(Counter);
      } else if (document.querySelectorAll('.post-title-link').length >= 1) {
        showTime(Counter);
      }
    });
  </script>






        
      </div>
    </footer>
  </div>

  
  
  <script color='0,0,255' opacity='0.5' zIndex='-1' count='99' src="/lib/canvas-nest/canvas-nest.min.js"></script>
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>
<script src="/js/utils.js"></script><script src="/js/motion.js"></script>
<script src="/js/schemes/pisces.js"></script>
<script src="/js/next-boot.js"></script>



  
  <script>
    (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      bp.src = (curProtocol === 'https') ? 'https://zz.bdstatic.com/linksubmit/push.js' : 'http://push.zhanzhang.baidu.com/push.js';
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>
















  

  

<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css">

<script>
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js', () => {
    var gitalk = new Gitalk({
      clientID: '0672eb3ee58faee4935d',
      clientSecret: '2de10f83bc44b7d86db607b2a3db41d6b845d59f',
      repo: 'itheone_gitalk',
      owner: 'hevolf',
      admin: ['hevolf'],
      id: 'cf410c6c4cea8189e20f4831f46a10cc',
        language: 'zh-CN',
      distractionFreeMode: 'true'
    });
    gitalk.render('gitalk-container');
  }, window.Gitalk);
</script>
<!-- calendar widget -->

    <script src="//cdn.jsdelivr.net/gh/theme-next/theme-next-calendar/calendar.min.js"></script>
    <script src="//cdn.jsdelivr.net/gh/theme-next/theme-next-calendar/languages.min.js"></script>
    <script>
    $(function() {
        $('#CloudCalendar').aCalendar('zh-CN',
            $.extend(
                '', {
                    single:true,
                    root:'/calendar/'
                }
            )
        );
    });
    </script>



<script>
NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
  var GUEST = ['nick', 'mail', 'link'];
  var guest = 'nick,mail';
  guest = guest.split(',').filter(item => {
    return GUEST.includes(item);
  });
  new Valine({
    el: '#comments',
    verify: false,
    notify: false,
    appId: '932Lws0WCoOBR1QH1YcClNyO-gzGzoHsz',
    appKey: 'qhb4dhObEw9qngzRpoxXrtEw',
    placeholder: "Just go go",
    avatar: 'mm',
    meta: guest,
    pageSize: '10' || 10,
    visitor: false,
    lang: '' || 'zh-cn',
    path: location.pathname,
    recordIP: false,
    serverURLs: ''
  });
}, window.Valine);
</script>

</body>
</html>